package pers.course.week7;

class Customer2 {
    String[] names;
    Account2 account = new Account2();
    public Customer2() {
        names = new String[2];
    }
    public Customer2(String f, String l) {
        this.names = new String[2];
        this.names[0] = f;
        this.names[1] = l;
    }
    public void setCustomer(String f, String l) {
        this.names[0] = f;
        this.names[1] = l;
    }
    public String getFirstName() {
        return this.names[0];
    }
    public String getLastName() {
        return this.names[1];
    }
    public Account2 getAccount() {
        return this.account;
    }
    public void setAccount(Account2 acct) {
        this.account = acct;
    }
}
class Account2 {
    double balance;
    public Account2() {
        this.balance = 0;
    }
    public Account2(double init_balance) {
        this.balance = init_balance;
    }
    public double getBalance() {
        return this.balance;
    }
    public boolean deposit(double amt) {
        this.balance += amt;
        return true;
    }
    public boolean withdraw(double amt) {
        if (this.balance > amt) {
            this.balance -= amt;
            return true;
        }
        return false;
    }
}
class Bank2 {
    Customer2[] customers;
    int numberOfCustomers = 0;
    public Bank2() {
        customers = new Customer2[100];
        for (int i = 0; i < customers.length; i++) {
            customers[i] = new Customer2();
        }
    }
    public void addCustomer(String f, String l) {
        this.customers[this.numberOfCustomers].setCustomer(f, l);
        this.numberOfCustomers++;
    }
    public int getNumOfCustomers() {
        return this.numberOfCustomers;
    }
    public Customer2 getCustomer(int index) {
        return this.customers[index];
    }
}
public class Conditionalize{
    public static void main(String[] args) {
        Customer2 customer;
        Account2 account;
// Create an account that can has a 500.00 balance.
        System.out.println("Creating the customer Jane Smith.");
        customer = new Customer2("Jane", "Smith");
        System.out.println("Creating her account with a 500.00 balance.");
        customer.setAccount(new Account2(500.00));
        account = customer.getAccount();
// Perform some account transactions
        System.out.println("Withdraw 150.00: " + account.withdraw(150.00));
        System.out.println("Deposit 22.50: " + account.deposit(22.50));
        System.out.println("Withdraw 47.62: " + account.withdraw(47.62));
        System.out.println("Withdraw 400.00: " + account.withdraw(400.00));
// Print out the final account balance
        System.out.println("Customer [" + customer.getLastName()
                + ", " + customer.getFirstName()
                + "] has a balance of " + account.getBalance());
    }
}
